package enums

import "github.com/gogf/gf/v2/errors/gcode"

/*
错误提示码管理
*/
type OpenResponseEnum struct {
	code    int
	message string
}

func (c OpenResponseEnum) Code() int {
	return c.code
}

func (c OpenResponseEnum) Message() string {
	return c.message
}

func (c OpenResponseEnum) Detail() interface{} {
	return nil
}

var (
	// 系统错误，httpStatus = 500
	Fail = New(500, "系统错误，请联系管理员")

	// httpStatus = 200
	Success = New(0, "SUCCESS")

	IllegalOperation = New(1000, "非法操作")
	IllegalArgument  = New(1001, "请求参数缺失")

	RequestParamTypeError  = New(1002, "请求参数错误")
	RequestMethodTypeError = New(1003, "请求方式错误")
	TransactionUserError   = New(1999, "用户重复请求或伪造请求")
)

func New(code int, message string) gcode.Code {
	return OpenResponseEnum{code: code, message: message}
}
